package com.aps.apspda.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.aps.apspda.R;
import com.aps.apspda.adapter.LoggingTCMListAdapter;
import com.aps.apspda.base.BaseActivity;
import com.aps.apspda.entity.InputDatasEntity;
import com.aps.apspda.myview.TitleView;
import com.aps.apspda.utils.StaticMembers;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.lzy.okgo.OkGo;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class LoggingTCMListActivity extends BaseActivity {


    @BindView(R.id.topView)
    TitleView topView;
    @BindView(R.id.tvEqpId)
    TextView tvEqpId;
    @BindView(R.id.rvDataList)
    RecyclerView rvDataList;

    public static LoggingTCMListActivity instance = null;
    private LoggingTCMListAdapter loggingTCMListAdapter;
   // private List<InputDatasEntity.InputObjects> inputList = new ArrayList<>();
    @Override
    protected int getLayoutResId() {
        return R.layout.activity_tcm_list;
    }

    @Override
    protected void initView() {
        instance = this;
        tvEqpId.setText(getIntent().getStringExtra("eqpID"));
        topView.setTitle("记录数据(" + StaticMembers.CUR_USER.getUSERNAME() + ")");
        rvDataList.setLayoutManager(new LinearLayoutManager(LoggingTCMListActivity.this));
        rvDataList.setItemAnimator(new DefaultItemAnimator());
        rvDataList.addItemDecoration(new DividerItemDecoration(LoggingTCMListActivity.this, 1));
        topView.setLeftListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {  LoggingTCMListActivity.this.finish(); }
        });
    }

    @Override
    protected void initData() {
        setData();
    }
    private void setData() {
        InputDatasEntity inputList = (InputDatasEntity) getIntent().getSerializableExtra("inputList");
        loggingTCMListAdapter = new LoggingTCMListAdapter(inputList.getINPUTDATA(),getEqpID(),getIntent().getStringExtra("eqpType"));
        loggingTCMListAdapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        loggingTCMListAdapter.setFragmentManager(getSupportFragmentManager());
        loggingTCMListAdapter.isFirstOnly(true);
        rvDataList.setAdapter(loggingTCMListAdapter);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        OkGo.getInstance().cancelTag(this);
    }
}
